package com.xhwl.centiotdata.handler.pedestrian.impl;

import com.xhwl.centiotdata.handler.pedestrian.PedestrianIntegrationFactory;
import com.xhwl.centiotdata.handler.pedestrian.PedestrianIntegrationHandler;
import com.xhwl.centiotdata.pojo.dto.pedestrian.PedestrianIntegrationConfigDTO;
import com.xhwl.centiotdata.suppliersystem.dnake.PedestrianDnakeHandler;
import com.xhwl.common.dto.cent.device.DeviceDTO;
import com.xhwl.common.enums.pedestrian.DoorActionEnum;
import com.xhwl.common.pojo.ResultJson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @description:
 * @author: wuyuhao
 * @createDate: 2023/5/4 9:11
 */
@Service
@Slf4j
public class PedestrianIntegrationDnakeHandler extends PedestrianIntegrationHandler {

    @Resource
    private PedestrianDnakeHandler pedestrianDnakeHandler;

    @Override
    public void afterPropertiesSet() throws Exception {
        // 狄耐克人行
        PedestrianIntegrationFactory.register(101, this);
    }

    @Override
    public ResultJson openDoor(PedestrianIntegrationConfigDTO configDTO, DeviceDTO deviceDTO, DoorActionEnum doorAction) {
        if (doorAction == DoorActionEnum.REMOTELY_OPEN) {
            return pedestrianDnakeHandler.openDoor(configDTO, deviceDTO);
        } else {
            return ResultJson.fail("无对应设备操作");
        }
    }

}
